home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / ftp4w26a / samples / pascal / useftp4w.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1996-06-10  |  18.8 KB  |  443 lines

  1. Unit UseFTP4W;
  2. {by Barbara Tikart  Polarwolf Hard & Software, D-63906 Erlenbach am Main}
  3. {and AStA Uni Konstanz (AStA = Allgemeiner Studierenden Ausschuss)}
  4. {eMail to Andreas.Tikart@uni-konstanz.de or AStA@uni-konstanz.de}
  5. {Declarations for FTP module to use with 'FTP4W' Version 2.2g or higher}
  6. {Released into Public Domain}
  7. {Get the newest version via http://www.uni-konstanz.de/studis/asta/software/index.html}
  8.  
  9. Interface
  10.  
  11. Uses WinTypes, WinProcs;
  12.  
  13. {-----------------------------------------------------------}
  14. {ASCII or binary tranfser}
  15.  
  16. Const TYPE_A = Ord ('A');
  17. Const TYPE_I = Ord ('I');
  18.  
  19. {-----------------------------------------------------------}
  20. {              Return codes of FTP functions                }
  21. {-----------------------------------------------------------}
  22.  
  23. Const FTPERR_OK = 0;                  {succesful function}
  24. Const FTPERR_ENTERPASSWORD = 1;       {userid need a password}
  25. Const FTPERR_ACCOUNTNEEDED = 2;       {user/pass OK but account required}
  26. Const FTPERR_CANCELBYUSER = -1;       {Transfer aborted by user FtpAbort}
  27.  
  28. {* user's or programmer's Errors}
  29. Const FTPERR_INVALIDPARAMETER = 1000; {Error in parameters}
  30. Const FTPERR_SESSIONUSED = 1001;      {User has already a FTP session}
  31. Const FTPERR_NOTINITIALIZED = 1002;   {FtpInit has not been call}
  32. Const FTPERR_NOTCONNECTED = 1003;     {User is not connected to a server}
  33. Const FTPERR_CANTOPENFILE = 1004;     {can not open specified file}
  34. Const FTPERR_CANTWRITE = 1005;        {can't write into file (disk full?)}
  35. Const FTPERR_NOACTIVESESSION = 1006;  {FtpRelease without FtpInit}
  36. Const FTPERR_STILLCONNECTED = 1007;   {FtpRelease without any Close}
  37. Const FTPERR_SERVERCANTEXECUTE = 1008;{file action not taken}
  38. Const FTPERR_LOGINREFUSED = 1009;     {Server rejects usrid/passwd}
  39. Const FTPERR_NOREMOTEFILE = 1010;     {server can not open file}
  40. Const FTPERR_TRANSFERREFUSED = 1011;  {Host refused the transfer}
  41. Const FTPERR_WINSOCKNOTUSABLE = 1012; {A winsock.DLL ver 1.1 is required}
  42. Const FTPERR_CANTCLOSE = 1013;        {close failed (cmd is in progress)}
  43. Const FTPERR_FILELOCKED = 1014;       {temporary error during FtpDelete}
  44.  
  45. {* TCP errors}
  46. Const FTPERR_UNKNOWNHOST = 2001;      {can not resolve host adress}
  47. Const FTPERR_NOREPLY = 2002;          {host does not send an answer}
  48. Const FTPERR_CANTCONNECT = 2003;      {Error during connection}
  49. Const FTPERR_CONNECTREJECTED = 2004;  {host has no FTP server}
  50. Const FTPERR_SENDREFUSED = 2005;      {can't send data (network down)}
  51. Const FTPERR_DATACONNECTION = 2006;   {connection on data-port failed}
  52. Const FTPERR_TIMEOUT = 2007;          {timeout occurred}
  53.  
  54. {* FTP errors}
  55. Const FTPERR_UNEXPECTEDANSWER = 3001; {answer was not expected}
  56. Const FTPERR_CANNOTCHANGETYPE = 3002; {host rejects the TYPE command}
  57. Const FTPERR_CMDNOTIMPLEMENTED = 3003;{host recognize but can't exec cmd}
  58. Const FTPERR_PWDBADFMT = 3004;        {PWD cmd OK, but answer has no "}
  59. Const FTPERR_PASVCMDNOTIMPL = 3005;   {Server don't support passive mode}
  60.  
  61. {* Resource errors}
  62. Const FTPERR_CANTCREATEWINDOW = 5002; {Insufficent free resources}
  63. Const FTPERR_INSMEMORY = 5003;        {Insufficient Heap memory}
  64. Const FTPERR_CANTCREATESOCKET = 5004; {no more socket}
  65. Const FTPERR_CANTBINDSOCKET = 5005;   {bind is not succesful}
  66. Const FTPERR_SYSTUNKNOWN = 5006;      {host system not in the list}
  67.  
  68. {-----------------------------------------------------------}
  69. {              FTP4W internal data structure                }
  70. {-----------------------------------------------------------}
  71.  
  72. Const FTP_DATABUFFER = 4096; {a good value for X25/Ethernet/Token Ring}
  73.  
  74. Type PFtp_Msg = ^TFtp_Msg;
  75.      TFtp_MSG = Record
  76.          hParentWnd: hWnd;        {window which the msg is to be passed}
  77.          nCompletedMessage: Word; {msg to be sent at end of the function}
  78.        End;
  79.  
  80.      PFtp_Verbose = ^TFtp_Verbose;
  81.      TFtp_Verbose = Record
  82.          hVerboseWnd: hWnd;  {window which the message is to be passed}
  83.          nVerboseMsg: Word;  {msg to be sent each time a line is received}
  84.        End;
  85.  
  86.      PFtp_FileTrf = ^TFtp_FileTrf;
  87.      TFtp_FileTrf = Record
  88.          hf: THandle;        {handle of the file which is being transfered}
  89.          nCount: Word;       {number of writes/reads made on a file}
  90.          nAsyncAlone: Word;  {pause each N frame in Async mode  (Def 40)}
  91.          nAsyncMulti: Word;  {Idem but more than one FTP sssion (Def 10)}
  92.          nDelay: Word;       {time of the pause in milliseconds}
  93.          bAborted: Bool;     {data transfer has been canceled}
  94.          szBuf : Array [0..FTP_DataBuffer-1] Of Char; {Data buffer}
  95.          bNotify: Bool;      {application receives a msg each data packet}
  96.          bAsyncMode: Bool;   {synchronous or asynchronous Mode}
  97.          lPos: LongInt;      {Bytes transfered}
  98.          lTotal: LongInt;    {bytes to be transfered}
  99.        End;
  100.  
  101.      PWinsock_in_addr = ^TWinsock_in_addr;
  102.      TWinsock_in_addr = Record
  103.          Case Byte Of
  104.              0: (B1, B2, B3, B4: Byte);
  105.            End;
  106.  
  107.      PWinsock_sockaddr_in = ^TWinsock_sockaddr_in;
  108.      TWinsock_sockaddr_in = Record
  109.          in_family: Integer;
  110.          in_port: Word;
  111.          in_addr: TWinsock_in_addr;
  112.          sin_zero: Array [0..7] Of Char;
  113.        End;
  114.  
  115.      PFtp_FtpData = ^TFtp_FtpData;
  116.      TFtp_FtpData = Record
  117.          ctrl_socket: Word;    {control stream       init INVALID_SOCKET}
  118.          data_socket: Word;    {data stream          init INVALID_SOCKET}
  119.          cType: Char;          {type (ASCII/binary)  init TYPE_A}
  120.          bVerbose: Bool;       {verbose mode         init FALSE}
  121.          bPassif: Bool;        {VRAI -> mode passif}
  122.          nPort: Integer;       {connexion Port       init FTP_DEFPORT}
  123.          nTimeOut: Integer;    {TimeOut in seconds   init FTP_DEFTIMEOUT}
  124.          hLogFile: THandle;    {Log file}
  125.          szInBuf: Array [0..1024-1] of Char; {incoming Buffer}
  126.          Unknown: Byte;        {Perhaps it is on the wrong Place}
  127.          saSockAddr: TWinsock_sockaddr_in;
  128.          saAcceptAddr: TWinsock_sockaddr_in;
  129.        End;
  130.  
  131.      PFtp_ProcData = ^TFtp_ProcData;
  132.      TFtp_ProcData = Record
  133.            { task data }
  134.          hTask: THandle;        {Task Id}
  135.          hFtpWindow: hWnd;      {Handle of the internal window}
  136.          hParentWnd: hWnd;      {handle given to the FtpInit function}
  137.          hInstance: THandle;    {Task Instance}
  138.          bRelease:  Bool;       {FtpRelease has been called}
  139.            {Mesasge information}
  140.          MSG: TFtp_Msg;
  141.          VMSG: TFtp_Verbose;
  142.            {File information}
  143.          FileTrf: TFtp_FileTrf;
  144.            {Ftp information}
  145.          Ftp: TFtp_FtpData;
  146.            {Linked list}
  147.          Next, Prev: PFtp_ProcData;  {Don't use}
  148.                               { TFtp_FtpData has wrong length}
  149.        End;
  150.  
  151. {-----------------------------------------------------------}
  152. {              FTP Import Functions                         }
  153. {-----------------------------------------------------------}
  154.  
  155. {* Init functions}
  156. Type TFtpInit = Function (hWindow: hWnd): Integer;
  157. Type TFtpRelease = Function : Integer;
  158.  
  159. {* Connection}
  160. Type TFtpLogin = Function (Host, User, Password: PChar; hWindow: hWnd; wMSG: Word): Integer;
  161. Type TFtpOpenConnection = Function (Host: PChar): Integer;
  162. Type TFtpCloseConnection = Function : Integer;
  163. Type TFtpLocalClose = Function : Integer;
  164.  
  165. {* authentification}
  166. Type TFtpSendUserName = Function (UserName: PChar): Integer;
  167. Type TFtpSendPasswd = Function (Passwd: PChar): Integer;
  168.  
  169. {* commands}
  170. Type TFtpHelp = Function (Arg, Buf: PChar; BufSize: Word): Integer;
  171. Type TFtpDeleteFile = Function (szRemoteFile: PChar): Integer;
  172. Type TFtpRenameFile = Function (szFrom, szTo: PChar): Integer;
  173. Type TFtpSyst = Function (szSystemStr: Pointer): Integer;
  174. Type TFtpCWD = Function (Path: PChar): Integer;
  175. Type TFtpQuote = Function (Cmd, ReplyBuf: PChar; BufSize: Integer): Integer;
  176. Type TFtpSetType = Function (Typ: Integer): Integer;
  177. Type TFtpCDUP = Function: Integer;
  178. Type TFtpPWD = Function (szBuf: PChar; uBufSize: Word): Integer;
  179. Type TFtpMKD = Function (szPath, szFullDir: PChar; uBufSize: Word): Integer;
  180. Type TFtpRMD = Function (szPath: PChar): Integer;
  181.  
  182. {* file transfer}
  183. Type TFtpAbort = Function : Integer;
  184. Type TFtpFlush = Function : Integer;
  185. Type TFtpSendFile = Function (Lcl, Remote: PChar; Typ: Integer; Notify :
  186.          Bool; hWindow: hWnd; wMSG: Word): Integer;
  187. Type TFtpRecvFile = Function (Remote, Lcl: PChar; Typ: Integer; Notify :
  188.          Bool; hWindow: hWnd; wMSG: Word): Integer;
  189. Type TFtpAppendToRemoteFile = Function (Lcl, Remote: PChar; Typ: Integer; Notify :
  190.          Bool; hWindow: hWnd; wMSG: Word): Integer;
  191. Type TFtpAppendToLocalFile = Function (Remote, Lcl: PChar; Typ: Integer; Notify :
  192.          Bool; hWindow: hWnd; wMSG: Word): Integer;
  193. Type TFtpGetFileSize = Function : LongInt;
  194.  
  195. {* Directory}
  196. Type TFtpDir = Function (Def, LocalFile: PChar; LongDir: Bool;
  197.          hWindow: hWnd; wMSG: Word): Integer;
  198.  
  199. {* specials}
  200. Type TFtpBytesTransferred =  Function : LongInt;
  201. Type TFtpBytesToBeTransferred = Function : LongInt;
  202. Type TFtpSetDefaultTimeOut = Procedure (nTo_in_sec: Integer);
  203. Type TFtpSetDefaultPort = Procedure (nDefPort: Integer);
  204. Type TFtpSetAsynchronousMode = Procedure;
  205. Type TFtpSetSynchronousMode =  Procedure;
  206. Type TFtpIsAsynchronousMode = Function : Bool;
  207. Type TFtpSetNewDelay = Procedure (X: Integer);
  208. Type TFtpSetNewSlices = Procedure (X, Y: Integer);
  209. Type TFtpSetPassiveMode = Procedure (bPassive: Bool);
  210. Type TFtpLogTo = Procedure (hLogFile: THandle);
  211.  
  212. {* Utilities functions}
  213. Type TWEP = Function (nType: Integer): Integer;
  214. Type TFtpSetVerboseMode = Function (bVerboseMode: Integer; hWindow: hWnd;
  215.   wMsg: Integer): Integer;
  216. Type TFtpDataPtr = Function: PFtp_ProcData;
  217. Type TFtp4wVer = Function (szVerStr: PChar; nStrSize: Word): Integer;
  218.  
  219. Var FtpInit : TFtpInit;
  220. Var FtpRelease: TFtpRelease;
  221. Var FtpLogin: TFtpLogin;
  222. Var FtpOpenConnection: TFtpOpenConnection;
  223. Var FtpCloseConnection: TFtpCloseConnection;
  224. Var FtpLocalClose: TFtpLocalClose;
  225. Var FtpSendUserName: TFtpSendUserName;
  226. Var FtpSendPasswd: TFtpSendPasswd;
  227. Var FtpHelp: TFtpHelp;
  228. Var FtpDeleteFile: TFtpDeleteFile;
  229. Var FtpRenameFile: TFtpRenameFile;
  230. Var FtpSyst: TFtpSyst;
  231. Var FtpCWD: TFtpCWD;
  232. Var FtpQuote: TFTPQuote;
  233. Var FtpSetType: TFtpSetType;
  234. Var FtpCDUP : TFtpCDUP;
  235. Var FtpPWD: TFtpPWD;
  236. Var FtpMKD: TFtpMKD;
  237. Var FtpRMD: TFtpRMD;
  238. Var FtpAbort: TFtpAbort;
  239. Var FtpFlush: TFtpFlush;
  240. Var FtpSendFile: TFtpSendFile;
  241. Var FtpRecvFile: TFtpRecvFile;
  242. Var FtpAppendToRemoteFile : TFtpAppendToRemoteFile;
  243. Var FtpAppendToLocalFile : TFtpAppendToLocalFile;
  244. Var FtpGetFileSize: TFtpGetFileSize;
  245. Var FtpDir: TFtpDir;
  246. Var FtpBytesTransferred: TFtpBytesTransferred;
  247. Var FtpBytesToBeTransferred: TFtpBytesToBeTransferred;
  248. Var FtpSetDefaultTimeOut: TFtpSetDefaultTimeOut;
  249. Var FtpSetDefaultPort: TFtpSetDefaultPort;
  250. Var FtpSetAsynchronousMode: TFtpSetAsynchronousMode;
  251. Var FtpSetSynchronousMode: TFtpSetSynchronousMode;
  252. Var FtpIsAsynchronousMode: TFtpIsAsynchronousMode;
  253. Var FtpSetNewDelay: TFtpSetNewDelay;
  254. Var FtpSetNewSlices: TFtpSetNewSlices;
  255. Var FtpSetPassiveMode: TFtpSetPassiveMode;
  256. Var FtpLogTo: TFtpLogTo;
  257.  
  258. Var WEP: TWEP;
  259. Var FtpSetVerboseMode: TFtpSetVerboseMode;
  260. Var FtpDataPtr: TFtpDataPtr;
  261. Var Ftp4wVer: TFtp4wVer;
  262.  
  263. {Unit-implemented Functions}
  264. Function FTP4W_Error (ErrorValue: Integer): PChar;
  265.  
  266. Implementation
  267.  
  268. Var hFtp4W: THandle;
  269.  
  270. Procedure LoadFtp4WDLL;
  271.   Var FP: TFarProc;
  272.   Begin
  273.     If hFtp4W >= 32 Then FreeLibrary (hFtp4W);
  274.     hFtp4W := LoadLibrary ('FTP4W.DLL');
  275.     If hFtp4W < 32 Then Exit;
  276.     FP := GetProcAddress (hFtp4W, 'FtpInit');
  277.     FtpInit := TFtpInit (FP);
  278.     FP := GetProcAddress (hFtp4W, 'FtpRelease');
  279.     FtpRelease := TFtpRelease (FP);
  280.     FP := GetProcAddress (hFtp4W, 'FtpLogin');
  281.     FtpLogin := TFtpLogin (FP);
  282.     FP := GetProcAddress (hFtp4W, 'FtpOpenConnection');
  283.     FtpOpenConnection := TFtpOpenConnection (FP);
  284.     FP := GetProcAddress (hFtp4W, 'FtpCloseConnection');
  285.     FtpCloseConnection := TFtpCloseConnection (FP);
  286.     FP := GetProcAddress (hFtp4W, 'FtpLocalClose');
  287.     FtpLocalClose := TFtpLocalClose (FP);
  288.     FP := GetProcAddress (hFtp4W, 'FtpSendUserName');
  289.     FtpSendUserName := TFtpSendUserName (FP);
  290.     FP := GetProcAddress (hFtp4W, 'FtpSendPasswd');
  291.     FtpSendPasswd := TFtpSendPasswd (FP);
  292.     FP := GetProcAddress (hFtp4W, 'FtpHelp');
  293.     FtpHelp := TFtpHelp (FP);
  294.     FP := GetProcAddress (hFtp4W, 'FtpDeleteFile');
  295.     FtpDeleteFile := TFtpDeleteFile (FP);
  296.     FP := GetProcAddress (hFtp4W, 'FtpRenameFile');
  297.     FtpRenameFile := TFtpRenameFile (FP);
  298.     FP := GetProcAddress (hFtp4W, 'FtpSyst');
  299.     FtpSyst := TFtpSyst (FP);
  300.     FP := GetProcAddress (hFtp4W, 'FtpCWD');
  301.     FtpCWD := TFtpCWD (FP);
  302.     FP := GetProcAddress (hFtp4W, 'FtpQuote');
  303.     FtpQuote := TFtpQuote (FP);
  304.     FP := GetProcAddress (hFtp4W, 'FtpSetType');
  305.     FtpSetType := TFtpSetType (FP);
  306.     FP := GetProcAddress (hFtp4W, 'FtpCDUP');
  307.     FtpCDUP := TFtpCDUP (FP);
  308.     FP := GetProcAddress (hFtp4W, 'FtpPWD');
  309.     FtpPWD := TFtpPWD (FP);
  310.     FP := GetProcAddress (hFtp4W, 'FtpMKD');
  311.     FtpMKD := TFtpMKD (FP);
  312.     FP := GetProcAddress (hFtp4W, 'FtpRMD');
  313.     FtpRMD := TFtpRMD (FP);
  314.     FP := GetProcAddress (hFtp4W, 'FtpAbort');
  315.     FtpAbort := TFtpAbort (FP);
  316.     FP := GetProcAddress (hFtp4W, 'FtpFlush');
  317.     FtpFlush := TFtpFlush (FP);
  318.     FP := GetProcAddress (hFtp4W, 'FtpSendFile');
  319.     FtpSendFile := TFtpSendFile (FP);
  320.     FP := GetProcAddress (hFtp4W, 'FtpRecvFile');
  321.     FtpRecvFile := TFtpRecvFile (FP);
  322.     FP := GetProcAddress (hFtp4W, 'FtpAppendToRemoteFile');
  323.     FtpAppendToRemoteFile := TFtpAppendToRemoteFile (FP);
  324.     FP := GetProcAddress (hFtp4W, 'FtpAppendToLocalFile');
  325.     FtpAppendToLocalFile := TFtpAppendToLocalFile (FP);
  326.     FP := GetProcAddress (hFtp4W, 'FtpGetFileSize');
  327.     FtpGetFileSize := TFtpGetFileSize (FP);
  328.     FP := GetProcAddress (hFtp4W, 'FtpDir');
  329.     FtpDir := TFtpDir (FP);
  330.     FP := GetProcAddress (hFtp4W, 'FtpBytesTransferred');
  331.     FtpBytesTransferred := TFtpBytesTransferred (FP);
  332.     FP := GetProcAddress (hFtp4W, 'FtpBytesToBeTransferred');
  333.     FtpBytesToBeTransferred := TFtpBytesToBeTransferred (FP);
  334.     FP := GetProcAddress (hFtp4W, 'FtpSetDefaultTimeOut');
  335.     FtpSetDefaultTimeOut := TFtpSetDefaultTimeOut (FP);
  336.     FP := GetProcAddress (hFtp4W, 'FtpSetDefaultPort');
  337.     FtpSetDefaultPort := TFtpSetDefaultPort (FP);
  338.     FP := GetProcAddress (hFtp4W, 'FtpSetAsynchronousMode');
  339.     FtpSetAsynchronousMode := TFtpSetAsynchronousMode (FP);
  340.     FP := GetProcAddress (hFtp4W, 'FtpSetSynchronousMode');
  341.     FtpSetSynchronousMode := TFtpSetSynchronousMode (FP);
  342.     FP := GetProcAddress (hFtp4W, 'FtpIsAsynchronousMode');
  343.     FtpIsAsynchronousMode := TFtpIsAsynchronousMode (FP);
  344.     FP := GetProcAddress (hFtp4W, 'FtpSetNewDelay');
  345.     FtpSetNewDelay := TFtpSetNewDelay (FP);
  346.     FP := GetProcAddress (hFtp4W, 'FtpSetNewSlices');
  347.     FtpSetNewSlices := TFtpSetNewSlices (FP);
  348.     FP := GetProcAddress (hFtp4W,  'FtpSetPassiveMode');
  349.     FtpSetPassiveMode := TFtpSetPassiveMode (FP);
  350.     FP := GetProcAddress (hFtp4W, 'FtpLogTo');
  351.     FtpLogTo := TFtpLogTo (FP);
  352.     FP := GetProcAddress (hFtp4W, 'WEP');
  353.     WEP := TWEP (FP);
  354.     FP := GetProcAddress (hFtp4W, 'FtpSetVerboseMode');
  355.     FtpSetVerboseMode := TFtpSetVerboseMode (FP);
  356.     FP := GetProcAddress (hFtp4W, 'FtpDataPtr');
  357.     FtpDataPtr := TFtpDataPtr (FP);
  358.     FP := GetProcAddress (hFtp4W, 'Ftp4wVer');
  359.     Ftp4wVer := TFtp4wVer (FP);
  360.   End;
  361.  
  362. Function FTP4W_Error (ErrorValue: Integer): PChar;
  363.   {return a PChar related to the ErrorValue given}
  364.   {as a parameter}
  365.   Var Msg: PChar;
  366.   Begin
  367.     Case ErrorValue Of
  368.         FTPERR_OK:               Msg := 'Ok';
  369.         FTPERR_ENTERPASSWORD:    Msg := 'Userid need a password';
  370.         FTPERR_ACCOUNTNEEDED:    Msg := 'User/pass OK but account required';
  371.         FTPERR_CANCELBYUSER:     Msg := 'Transfer aborted by user FtpAbort';
  372.         FTPERR_INVALIDPARAMETER: Msg := 'Error in parameters';
  373.         FTPERR_SESSIONUSED:      Msg := 'User has already a FTP session';
  374.         FTPERR_NOTINITIALIZED:   Msg := 'FtpInit has not been called';
  375.         FTPERR_NOTCONNECTED:     Msg := 'User is not connected to a server';
  376.         FTPERR_CANTOPENFILE:     Msg := 'Can not open specified file';
  377.         FTPERR_CANTWRITE:        Msg := 'Can'#39't write into file (disk full?)';
  378.         FTPERR_NOACTIVESESSION:  Msg := 'FtpRelease without FtpInit';
  379.         FTPERR_STILLCONNECTED:   Msg := 'FtpRelease without any Close';
  380.         FTPERR_SERVERCANTEXECUTE:Msg := 'File action not taken';
  381.         FTPERR_LOGINREFUSED:     Msg := 'Server rejects Userid/Passwd';
  382.         FTPERR_NOREMOTEFILE:     Msg := 'Server can not open file';
  383.         FTPERR_TRANSFERREFUSED:  Msg := 'Host refused the transfer';
  384.         FTPERR_WINSOCKNOTUSABLE: Msg := 'A winsock.DLL version 1.1 is required';
  385.         FTPERR_CANTCLOSE:        Msg := 'Close failed (cmd is in progress)';
  386.         FTPERR_FILELOCKED:       Msg := 'temporary error during FtpDelete';
  387.         FTPERR_UNKNOWNHOST:      Msg := 'Can not resolve host address';
  388.         FTPERR_NOREPLY:          Msg := 'Host does not send an answer';
  389.         FTPERR_CANTCONNECT:      Msg := 'Error during connection';
  390.         FTPERR_CONNECTREJECTED:  Msg := 'Host has no FTP server';
  391.         FTPERR_SENDREFUSED:      Msg := 'Can'#39't send data (network down)';
  392.         FTPERR_DATACONNECTION:   Msg := 'Connection on data-port failed';
  393.         FTPERR_TIMEOUT:          Msg := 'Timeout occurred';
  394.         FTPERR_UNEXPECTEDANSWER: Msg := 'Answer was not expected';
  395.         FTPERR_CANNOTCHANGETYPE: Msg := 'Host rejects the TYPE command';
  396.         FTPERR_CMDNOTIMPLEMENTED:Msg := 'host recognize but can'#39't exec cmd';
  397.         FTPERR_PWDBADFMT:        Msg := 'PWD cmd OK, but answer has no "';
  398.         FTPERR_PASVCMDNOTIMPL:   Msg := 'Server don'#39't support passive mode';
  399.         FTPERR_CANTCREATEWINDOW: Msg := 'Insufficent free resources';
  400.         FTPERR_INSMEMORY:        Msg := 'Insufficient Heap memory';
  401.         FTPERR_CANTCREATESOCKET: Msg := 'No more socket';
  402.         FTPERR_CANTBINDSOCKET:   Msg := 'Bind is not succesful';
  403.         FTPERR_SYSTUNKNOWN:      Msg := 'host system not in the list';
  404.       Else Msg := 'Unknown Error';
  405.       End;
  406.     FTP4W_Error := MSG;
  407.   End;
  408.  
  409. Var SaveExitProc: Pointer;
  410.  
  411. Procedure MyExitProc; Far;
  412.   Begin
  413.     ExitProc := SaveExitProc;
  414.     If hFtp4W >= 32 Then
  415.       Begin
  416.         FtpAbort;
  417.         FtpFlush;
  418.         FtpCloseConnection;
  419.         FtpLocalClose;
  420.         FTPRelease;
  421.         FreeLibrary (hFtp4W)
  422.       End
  423.   End;
  424.  
  425. Begin
  426.   hFtp4W := 0;
  427.   SaveExitProc := ExitProc;
  428.   ExitProc := @MyExitProc;
  429.   LoadFtp4WDLL;
  430.   If hFtp4W < 32 Then
  431.     Begin
  432.       MessageBox (0, 'FTP4W.DLL not found', 'FTP4W',
  433.         mb_IconStop Or mb_SystemModal Or mb_Ok);
  434.       Halt;
  435.     End;
  436.   If @Ftp4wVer = NIL Then
  437.     Begin
  438.       MessageBox (0, 'Unsupported Version of FTP4W', 'FTP4W',
  439.         mb_IconStop Or mb_SystemModal Or mb_Ok);
  440.       Halt;
  441.     End;
  442. End.
  443.